package com.senseauto.aicamera;

import android.graphics.SurfaceTexture;
import android.media.ImageReader;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.senseauto.aicamera.camera.Camera2Proxy;
import com.senseauto.aicamera.view.Camera2GLSurfaceView;

/**
 * 前面的界面已经申请过camera的权限了
 */
public class GLSurfaceViewActivity extends AppCompatActivity {
    String TAG = "GLSurfaceViewActivity";
    private Camera2GLSurfaceView mCameraView;
    private Camera2Proxy mCameraProxy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glsurface_view);
        mCameraView = findViewById(R.id.id_gl_sv);
        mCameraProxy = mCameraView.getCameraProxy();
    }

    private ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() {
        @Override
        public void onImageAvailable(ImageReader reader) {
            Log.e(TAG, "onImageAvailable");
        }
    };
    @Override
    protected void onResume() {
        super.onResume();
        mCameraView.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();
        mCameraView.onPause();
    }
    @Override
    protected void onStop() {
        super.onStop();
        mCameraProxy.stopPreview();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCameraProxy.releaseCamera();
    }
}